package com.yimidida.library.base;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

/**
 * Create on: 9/14/21
 * by Mr.Zhu
 * Description: fragment基类
 */
public abstract class BaseFragment<V extends BaseView, T extends BasePresenter<V>> extends Fragment
        implements BaseView {

    protected T mPresenter;//presenter实例

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPresenter = initPresenter();
        if (mPresenter != null) {
            mPresenter.attach((V) this);
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPresenter != null) {
            mPresenter.dettach();
        }
    }

    //初始化presenter
    protected abstract T initPresenter();

}
